//
//  SGJGrabOrderCell.m
//  Sewage
//
//  Created by 优聚泰元 on 2017/6/1.
//  Copyright © 2017年 宗庆猛. All rights reserved.
//

#import "SGJGrabOrderCell.h"

#import "UIColor+sewageColor.h"

@interface SGJGrabOrderCell ()
//属性名称，属性View最好服务器返回了再行决定。 也好一一对应。方便理解。
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;

@property (weak, nonatomic) IBOutlet UILabel *taskIdLabel;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *lineTrailLabel;
@property (weak, nonatomic) IBOutlet UILabel *lineLengthLabel;

@property (weak, nonatomic) IBOutlet UILabel *estimateTimeLabel;

@property (weak, nonatomic) IBOutlet UILabel *finishTimeLabel;
@property (weak, nonatomic) IBOutlet UIButton *grabOrderButton;
@end

@implementation SGJGrabOrderCell
- (IBAction)checkDetailButtonClick:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(checkDetailWithGrabOrderCell:)]) {
        [self.delegate checkDetailWithGrabOrderCell:self];
    }
}
- (IBAction)grabOrderButtonClick:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(grabOrderWithGrabOrderCell:)]) {
        [self.delegate grabOrderWithGrabOrderCell:self];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.grabOrderButton.layer.borderWidth = 1;
    self.grabOrderButton.layer.borderColor = [UIColor blueColor].CGColor;
    self.grabOrderButton.layer.cornerRadius = 15;
    self.grabOrderButton.clipsToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setGrabOrderModel:(SGJGrabOrderModel *)grabOrderModel{
    _grabOrderModel = grabOrderModel;
    
    self.nameLabel.text = grabOrderModel.name;
    self.lineTrailLabel.text = grabOrderModel.lineTrail;
    self.lineLengthLabel.text = [NSString stringWithFormat:@"%@公里",grabOrderModel.lineLength];
    self.estimateTimeLabel.text = [NSString stringWithFormat:@"%@分钟",grabOrderModel.estimateTime];
    self.finishTimeLabel.text = [NSString stringWithFormat:@"接单后 %@ 分钟内完成",grabOrderModel.finishTime];
    
    if (grabOrderModel.type == 0) {
        //self.typeLabel.backgroundColor = [UIColor colorFromHexString:@"#e86740"];
        self.typeLabel.backgroundColor = [UIColor sewageColorOrange1];
        self.typeLabel.text = @"一体化巡检";
        
        self.taskIdLabel.layer.borderWidth = 1;
        self.taskIdLabel.layer.borderColor = self.typeLabel.backgroundColor.CGColor;
        
        
    }else{
        self.typeLabel.backgroundColor = [UIColor sewageColorOrange1];
        self.typeLabel.text = @"官网巡检";
        
        self.taskIdLabel.layer.borderWidth = 1;
        self.taskIdLabel.layer.borderColor = self.typeLabel.backgroundColor.CGColor;
    }

}

@end
